package com.cat.model.dao.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.cat.model.common.model.common.Person;

/**
 * 使用注解的时候一定要将XXXMapper注册一下，跟XML配置namespace一样
 * 这里面主要到DefaultSessionFactory类中注册
 * @author Administrator
 *
 */
public interface PersonMapper {

	@Select("select * from person")
	public List<Person> getAll();

	@Select("select * from person where id=#{id}")
	public Person getPerson(@Param("id") int id);
	
	@Select("select * from person where age<#{age} and sex=#{sex}")
	public List<Person> getPersonsByMap(Map<String, Object> map);
	
	@Select("select * from person where age<#{age} and sex=#{sex}")
	public List<Person> getPersons(@Param("age") int age, @Param("sex") String sex);

	@Update("update person set sex=#{sex} where id=#{id}")
	public int updPerson(@Param("id") int id, @Param("sex") String sex);

	@Insert("insert into person(id, age, sex, name, password) values(null, #{age}, #{sex}, #{name}, #{password})")
	public void insertPerson(Person p);

	@Delete("delete from person where id=#{id}")
	public void delPerson(@Param("id") int id);

	@Update("update person set sex=#{sex}, name=#{name}, age=#{age}, password=#{password} where id=#{id}")
	public void updatePerson(Person p);
}
